package com.woniuxy.config;

import com.woniuxy.filter.LoginFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @program: bookstore
 * @description:
 * @create: 2024-10-08 16:42
 **/
@Configuration
public class WebFilter {
    @Autowired
    private LoginFilter loginFilter;


    //把方法返回值放入容器，名字是方法名
    @Bean
    public FilterRegistrationBean loginFilters() {
        FilterRegistrationBean frb = new FilterRegistrationBean();
        frb.setFilter(loginFilter);//放行 自定义过滤器
        frb.addUrlPatterns("/*");//配置拦截器规则
        frb.setOrder(1);//指定过滤器执行顺序，数值越小越先执行
        return frb;
    }

//    @Bean
//    public FilterRegistrationBean bloomFilter(){
//        FilterRegistrationBean frb = new FilterRegistrationBean();
//        frb.setFilter(bloomFilter); // 将自定义的布隆过滤器注册为过滤器
//        frb.addUrlPatterns("/*"); // 配置拦截的 URL 范围
//        frb.setOrder(2); // 设置布隆过滤器的执行顺序
//        return frb;
//    }
}
